Merge branch 'master' of https://github.com/iluwatar/java-design-patterns
This commit is contained in:
commit
2502ac2732
10
README.md
10
README.md
@ -47,7 +47,7 @@ Structural patterns are concerned with how classes and objects are composed to f
|
||||
|
||||
### Behavioral Patterns
|
||||
|
||||
Behavioral patterns are concerned with algorithms and the assignment of responsibilites between objects.
|
||||
Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects.
|
||||
|
||||
* [Chain of responsibility](#chain-of-responsibility)
|
||||
* [Command](#command)
|
||||
@ -228,7 +228,7 @@ A programming idiom is a means of expressing a recurring construct in one or mor
|
||||
**Applicability:** Use Decorator
|
||||
* to add responsibilities to individual objects dynamically and transparently, that is, without affecting other objects
|
||||
* for responsibilities that can be withdrawn
|
||||
* when extension by subclassing is impractical. Sometimes a large number of independent extensions are possible and would produce an explosion of sublasses to support every combination. Or a class definition may be hidden or otherwise unavailable for subclassing
|
||||
* when extension by subclassing is impractical. Sometimes a large number of independent extensions are possible and would produce an explosion of subclasses to support every combination. Or a class definition may be hidden or otherwise unavailable for subclassing
|
||||
|
||||
## <a name="facade">Facade</a> [↑](#list-of-design-patterns)
|
||||
**Intent:** Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.
|
||||
@ -283,7 +283,7 @@ A programming idiom is a means of expressing a recurring construct in one or mor
|
||||
|
||||

|
||||
|
||||
**Applicability:** The service locator pattern is applicable whenever we want to locate/fetch various services using JNDI which, typically, is a redundant and expensive lookup. The service Locator pattern addresses this expensive lookup by making use of caching techniques ie. for the very first time a particular service is requested, the service Locator looks up in JNDI, fetched the relavant service and then finally caches this service object. Now, further lookups of the same service via Service Locator is done in its cache which improves the performance of application to great extent.
|
||||
**Applicability:** The service locator pattern is applicable whenever we want to locate/fetch various services using JNDI which, typically, is a redundant and expensive lookup. The service Locator pattern addresses this expensive lookup by making use of caching techniques ie. for the very first time a particular service is requested, the service Locator looks up in JNDI, fetched the relevant service and then finally caches this service object. Now, further lookups of the same service via Service Locator is done in its cache which improves the performance of application to great extent.
|
||||
|
||||
**Typical Use Case:**
|
||||
|
||||
@ -686,7 +686,7 @@ validation and for building to order
|
||||
**Applicability:** Use the Front Controller pattern when
|
||||
* you want to encapsulate common request handling functionality in single place
|
||||
* you want to implements dynamic request handling i.e. change routing without modifying code
|
||||
* make web server configution portable, you only need to register the handler web server specific way
|
||||
* make web server configuration portable, you only need to register the handler web server specific way
|
||||
|
||||
**Real world examples:**
|
||||
* [Apache Struts](https://struts.apache.org/)
|
||||
@ -711,7 +711,7 @@ validation and for building to order
|
||||

|
||||
|
||||
**Applicability:** Use the Business Delegate pattern when
|
||||
* you want loose couping between presentation and business tiers
|
||||
* you want loose coupling between presentation and business tiers
|
||||
* you want to orchestrate calls to multiple business services
|
||||
* you want to encapsulate service lookups and service calls
|
||||
|
||||
|
@ -72,7 +72,7 @@
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<datanucleus-maven-plugin.version>4.0.0-release</datanucleus-maven-plugin.version>
|
||||
<datanucleus-maven-plugin.version>4.0.1</datanucleus-maven-plugin.version>
|
||||
</properties>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
|
@ -70,7 +70,7 @@ public class SimpleObjects {
|
||||
final String name
|
||||
) {
|
||||
return container.allMatches(
|
||||
new QueryDefault<SimpleObject>(
|
||||
new QueryDefault<>(
|
||||
SimpleObject.class,
|
||||
"findByName",
|
||||
"name", name));
|
||||
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package domainapp.fixture;
|
||||
|
||||
import org.apache.isis.applib.annotation.DomainService;
|
||||
import org.apache.isis.applib.annotation.NatureOfService;
|
||||
import org.apache.isis.applib.fixturescripts.FixtureScripts;
|
||||
import org.apache.isis.applib.services.fixturespec.FixtureScriptsSpecification;
|
||||
import org.apache.isis.applib.services.fixturespec.FixtureScriptsSpecificationProvider;
|
||||
|
||||
import domainapp.fixture.scenarios.RecreateSimpleObjects;
|
||||
|
||||
/**
|
||||
* Specifies where to find fixtures, and other settings.
|
||||
*/
|
||||
@DomainService(nature = NatureOfService.DOMAIN)
|
||||
public class DomainAppFixturesProvider implements FixtureScriptsSpecificationProvider {
|
||||
@Override
|
||||
public FixtureScriptsSpecification getSpecification() {
|
||||
return FixtureScriptsSpecification
|
||||
.builder(DomainAppFixturesProvider.class)
|
||||
.with(FixtureScripts.MultipleExecutionStrategy.EXECUTE)
|
||||
.withRunScriptDefault(RecreateSimpleObjects.class)
|
||||
.withRunScriptDropDown(FixtureScriptsSpecification.DropDownPolicy.CHOICES)
|
||||
.withRecreate(RecreateSimpleObjects.class)
|
||||
.build();
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package domainapp.fixture;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.isis.applib.annotation.Action;
|
||||
import org.apache.isis.applib.annotation.ActionLayout;
|
||||
import org.apache.isis.applib.annotation.DomainService;
|
||||
import org.apache.isis.applib.annotation.DomainServiceLayout;
|
||||
import org.apache.isis.applib.annotation.MemberOrder;
|
||||
import org.apache.isis.applib.annotation.RestrictTo;
|
||||
import org.apache.isis.applib.fixturescripts.FixtureResult;
|
||||
import org.apache.isis.applib.fixturescripts.FixtureScript;
|
||||
import org.apache.isis.applib.fixturescripts.FixtureScripts;
|
||||
|
||||
import domainapp.fixture.scenarios.RecreateSimpleObjects;
|
||||
|
||||
/**
|
||||
* Enables fixtures to be installed from the application.
|
||||
*/
|
||||
@DomainService
|
||||
@DomainServiceLayout(
|
||||
named="Prototyping",
|
||||
menuBar = DomainServiceLayout.MenuBar.SECONDARY,
|
||||
menuOrder = "500"
|
||||
)
|
||||
public class DomainAppFixturesService extends FixtureScripts {
|
||||
|
||||
public DomainAppFixturesService() {
|
||||
super(DomainAppFixturesService.class.getPackage().getName(), MultipleExecutionStrategy.EXECUTE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FixtureScript default0RunFixtureScript() {
|
||||
return findFixtureScriptFor(RecreateSimpleObjects.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FixtureScript> choices0RunFixtureScript() {
|
||||
return super.choices0RunFixtureScript();
|
||||
}
|
||||
|
||||
|
||||
// //////////////////////////////////////
|
||||
|
||||
@Action(
|
||||
restrictTo = RestrictTo.PROTOTYPING
|
||||
)
|
||||
@ActionLayout(
|
||||
cssClassFa="fa fa-refresh"
|
||||
)
|
||||
@MemberOrder(sequence="20")
|
||||
public Object recreateObjectsAndReturnFirst() {
|
||||
final List<FixtureResult> run = findFixtureScriptFor(RecreateSimpleObjects.class).run(null);
|
||||
return run.get(0).getObject();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -26,7 +26,7 @@ public class SimpleObjectsTearDown extends FixtureScript {
|
||||
|
||||
@Override
|
||||
protected void execute(ExecutionContext executionContext) {
|
||||
isisJdoSupport.executeUpdate("delete from simple.\"SimpleObject\"");
|
||||
isisJdoSupport.executeUpdate("delete from \"simple\".\"SimpleObject\"");
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,17 +84,38 @@
|
||||
<artifactId>hsqldb</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- uncomment to enable enhanced cucumber-jvm reporting http://www.masterthought.net/section/cucumber-reporting
|
||||
<dependency> <groupId>com.googlecode.totallylazy</groupId> <artifactId>totallylazy</artifactId>
|
||||
<version>991</version> </dependency> <dependency> <groupId>net.masterthought</groupId>
|
||||
<artifactId>cucumber-reporting</artifactId> <version>0.0.21</version> </dependency>
|
||||
<dependency> <groupId>net.masterthought</groupId> <artifactId>maven-cucumber-reporting</artifactId>
|
||||
<version>0.0.4</version> </dependency> -->
|
||||
</dependencies>
|
||||
<!--
|
||||
uncomment to enable enhanced cucumber-jvm reporting
|
||||
http://www.masterthought.net/section/cucumber-reporting
|
||||
<dependency>
|
||||
<groupId>com.googlecode.totallylazy</groupId>
|
||||
<artifactId>totallylazy</artifactId>
|
||||
<version>991</version>
|
||||
</dependency>
|
||||
|
||||
<!-- uncomment for enhanced cucumber-jvm reporting http://www.masterthought.net/section/cucumber-reporting
|
||||
<repositories> <repository> <id>repo.bodar.com</id> <url>http://repo.bodar.com</url>
|
||||
</repository> </repositories> -->
|
||||
<dependency>
|
||||
<groupId>net.masterthought</groupId>
|
||||
<artifactId>cucumber-reporting</artifactId>
|
||||
<version>0.0.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.masterthought</groupId>
|
||||
<artifactId>maven-cucumber-reporting</artifactId>
|
||||
<version>0.0.4</version>
|
||||
</dependency>
|
||||
-->
|
||||
</dependencies>
|
||||
|
||||
<!--
|
||||
uncomment for enhanced cucumber-jvm reporting
|
||||
http://www.masterthought.net/section/cucumber-reporting
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repo.bodar.com</id>
|
||||
<url>http://repo.bodar.com</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
-->
|
||||
|
||||
|
||||
</project>
|
||||
|
@ -240,61 +240,52 @@
|
||||
<exclude>**/translations*.po</exclude>
|
||||
</excludes>
|
||||
<licenses>
|
||||
<license
|
||||
implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
|
||||
<licenseFamilyCategory>AL2</licenseFamilyCategory>
|
||||
<licenseFamilyName>Apache License 2.0</licenseFamilyName>
|
||||
<notes />
|
||||
<patterns>
|
||||
<pattern>Licensed to the Apache Software Foundation (ASF) under
|
||||
one</pattern>
|
||||
</patterns>
|
||||
</license>
|
||||
<license
|
||||
implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
|
||||
<licenseFamilyCategory>JQRY</licenseFamilyCategory>
|
||||
<licenseFamilyName>MIT</licenseFamilyName>
|
||||
<notes />
|
||||
<patterns>
|
||||
<pattern>Dual licensed under the MIT or GPL Version 2 licenses.</pattern>
|
||||
</patterns>
|
||||
</license>
|
||||
<license
|
||||
implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
|
||||
<licenseFamilyCategory>JMOCK</licenseFamilyCategory>
|
||||
<licenseFamilyName>JMock</licenseFamilyName>
|
||||
<notes />
|
||||
<patterns>
|
||||
<pattern>Copyright (c) 2000-2007, jMock.org</pattern>
|
||||
</patterns>
|
||||
</license>
|
||||
<license
|
||||
implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
|
||||
<licenseFamilyCategory>DOCBK</licenseFamilyCategory>
|
||||
<licenseFamilyName>DocBook 4.5</licenseFamilyName>
|
||||
<notes />
|
||||
<patterns>
|
||||
<pattern>Permission to copy in any form is granted for use</pattern>
|
||||
<pattern>Permission to use, copy, modify and distribute the
|
||||
DocBook DTD</pattern>
|
||||
<pattern>is hereby granted in perpetuity, provided that the
|
||||
above copyright</pattern>
|
||||
<pattern>This is the catalog data file for DocBook XML V4.5. It
|
||||
is provided as</pattern>
|
||||
<pattern>XML Catalog data for DocBook XML V4.5</pattern>
|
||||
<pattern>DocBook additional general entities V4.5</pattern>
|
||||
<pattern>XML EXCHANGE TABLE MODEL DECLARATION MODULE</pattern>
|
||||
</patterns>
|
||||
</license>
|
||||
<license
|
||||
implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
|
||||
<licenseFamilyCategory>W3C</licenseFamilyCategory>
|
||||
<licenseFamilyName>XHTML</licenseFamilyName>
|
||||
<notes />
|
||||
<patterns>
|
||||
<pattern>Copyright (c) 1998-2002 W3C (MIT, INRIA, Keio),</pattern>
|
||||
</patterns>
|
||||
</license>
|
||||
<license implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
|
||||
<licenseFamilyCategory>AL2</licenseFamilyCategory>
|
||||
<licenseFamilyName>Apache License 2.0</licenseFamilyName>
|
||||
<notes/>
|
||||
<patterns>
|
||||
<pattern>Licensed to the Apache Software Foundation (ASF) under one</pattern>
|
||||
</patterns>
|
||||
</license>
|
||||
<license implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
|
||||
<licenseFamilyCategory>JQRY</licenseFamilyCategory>
|
||||
<licenseFamilyName>MIT</licenseFamilyName>
|
||||
<notes/>
|
||||
<patterns>
|
||||
<pattern>Dual licensed under the MIT or GPL Version 2 licenses.</pattern>
|
||||
</patterns>
|
||||
</license>
|
||||
<license implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
|
||||
<licenseFamilyCategory>JMOCK</licenseFamilyCategory>
|
||||
<licenseFamilyName>JMock</licenseFamilyName>
|
||||
<notes/>
|
||||
<patterns>
|
||||
<pattern>Copyright (c) 2000-2007, jMock.org</pattern>
|
||||
</patterns>
|
||||
</license>
|
||||
<license implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
|
||||
<licenseFamilyCategory>DOCBK</licenseFamilyCategory>
|
||||
<licenseFamilyName>DocBook 4.5</licenseFamilyName>
|
||||
<notes/>
|
||||
<patterns>
|
||||
<pattern>Permission to copy in any form is granted for use</pattern>
|
||||
<pattern>Permission to use, copy, modify and distribute the DocBook DTD</pattern>
|
||||
<pattern>is hereby granted in perpetuity, provided that the above copyright</pattern>
|
||||
<pattern>This is the catalog data file for DocBook XML V4.5. It is provided as</pattern>
|
||||
<pattern>XML Catalog data for DocBook XML V4.5</pattern>
|
||||
<pattern>DocBook additional general entities V4.5</pattern>
|
||||
<pattern>XML EXCHANGE TABLE MODEL DECLARATION MODULE</pattern>
|
||||
</patterns>
|
||||
</license>
|
||||
<license implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
|
||||
<licenseFamilyCategory>W3C</licenseFamilyCategory>
|
||||
<licenseFamilyName>XHTML</licenseFamilyName>
|
||||
<notes/>
|
||||
<patterns>
|
||||
<pattern>Copyright (c) 1998-2002 W3C (MIT, INRIA, Keio),</pattern>
|
||||
</patterns>
|
||||
</license>
|
||||
</licenses>
|
||||
<licenseFamilies>
|
||||
<licenseFamily implementation="org.apache.rat.license.SimpleLicenseFamily">
|
||||
|
@ -236,8 +236,7 @@
|
||||
<tasks>
|
||||
<exec executable="java" failonerror="true">
|
||||
<arg value="-jar" />
|
||||
<arg
|
||||
value="${project.build.directory}/${project.build.finalName}-jetty-console.jar" />
|
||||
<arg value="${project.build.directory}/${project.build.finalName}-jetty-console.jar" />
|
||||
</exec>
|
||||
</tasks>
|
||||
</configuration>
|
||||
@ -303,10 +302,8 @@
|
||||
<arg value="-Dtarget.dir=${target.dir}" />
|
||||
|
||||
<arg value="-Drebel.plugins=${isis_jrebel_plugin.jar}" />
|
||||
<arg
|
||||
value="-Disis-jrebel-plugin.packagePrefix=${isis-jrebel-plugin.packagePrefix}" />
|
||||
<arg
|
||||
value="-Disis-jrebel-plugin.loggingLevel=${isis-jrebel-plugin.loggingLevel}" />
|
||||
<arg value="-Disis-jrebel-plugin.packagePrefix=${isis-jrebel-plugin.packagePrefix}" />
|
||||
<arg value="-Disis-jrebel-plugin.loggingLevel=${isis-jrebel-plugin.loggingLevel}" />
|
||||
<arg value="-XX:MaxPermSize=128m" />
|
||||
<arg value="-classpath" />
|
||||
<arg value="${runtime_classpath}" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user