� �
�������������� ������� �������������������
�������������������������
��������������
�����������������������
��������������������������������
��� �� ������� ����!���"#���$##%
� �
� ������������������
� �
� ������������������
����������������������
������������
&�������
�'�(
'�����
&������
)'(�&
)����
)�����
��)*
��)�+�&
�'�
����
$##,
��-
$##�
��������������� ��
� ���������������� �!"
� ���������#������ �$"
'���.
$##/
��.
$##%
$."
���
$##0
$."."
����������"
.#."
����
$#"#
� �
� �������
� ��&�������-� 1����2���������2��������2� ��������
� '����������$##,����3��.����
� '�!����3����
� �����-�4��)�+'52�������4��)�6'52����77�-�4���52�
�����������4&����52�8����9�4��'52�������������:
� ������������'����� �����������9�����-�����8����'�����
� �������,�;���+� �������<�������������
� �����&����������'������� ����8�����
� �
%��� �� ������������
� �
� ��������&���&���'���
� =������:���������������� ����������������3���
� ����������8����'���������������������������:��������
� +�����������������������������������-
� '����:�������!-�8����������������
� &��������������������-����������������������
� ����������.#."��������������$#"#�����������
� ��������������� ����2�3������2�+>�(2��?�!����@�A�
� "##B�!�:� ����2�...
� ����������������
� ����������."����$#"#2�.$����$#""2�?����$#"$
� &��������:2���������7��������2�&��������2��������7�����
� ��������������C;;:���� ���.��:;�������
� �
(��
��������������������D����
����������
� �
� <�������������������� ���������������� ����
� ����������-�� ��������������������������� ����
)��� �������� ��� �*����+
� �
�������,������
� ����-����������������������������� ���
������������������������-�����
$ asadmin redeploy --propertieskeepSessions=true myapp.war
� ������-������� �������
�����������������:�
� <���:���������< ��
� �
-���������&�� ���������#
� �
.��� �������(������
� ��������C��������������48'��5
� �������!���C�>E$
� F�����-������G
� �
��������
)��/����)
������
��������
�� ��0�
����������
�����������
'�����
�'�
��*
��'
+�<;<<8�
�� �����
��������
�� ��0#
+�!���
'����!��
&��
�&�
��������
�������
�� ��01
��6�!�'������
6'
����:�����
����-����
��������
�������
����� �!
������
����������
�����������
��*�
����".#
6'�H
�'�
�������
������
����� �$
������
����������
4D�!5
��*�."
����$.#
'������.#
�'��$.#
��)�+'�"."
& <�".#
I<�3���
*����@������J
23�)���
.���&�4��
����� 5���3����������
����� �$�6�2���7��8'9
� '��������D���<�
� 6�!���� ���
� �������!����-�K����::�!����-
� ��������-�<�3������
� <����������������-���<�
� ��*�."
� ����$.#
� '������.#
� �'��$.#
� ��)�+'�"."
� &����������".�
� *����@����������".#
� <�".#
� & <�".#
� ����:���*�����".#
� <������������"."
� ��)�6'�$.$
� �'+�"#%�".
� �'��$.$�;��(�$.$
� �'+�$,#�"."
8'�������*������*����������
��:;,�
� +�'� ���D�!�����������<
� ������-�D����-��������
� +����-���:������2���:�������>������<
� �����������!��������:������:������
� ���:�����������<�D����������
� ��)�+'�"."�����:�������D������*�
��:;,�����* ����
����������� ������������ ���������������� �������������������� �� ���� ���������������� �� ���� ���������������������������������������
���������������
��������������� ��� ���� ���������������������
4���<� ���������0=
��������������� ��
������������� !����������������� �� � ���� ���!����������!����� � �
������"�� ���������� �#$
������
���%&��&�����"��������"�� �'�����(�������($
�
�����������'�����(��
���%&��&����%��) �����*��
������"�� ����������� $
������
�
��L�������������
�!3����:����
���������
4�� ��������'�+
� !����#$%&���#$��'�� �����"�������(����"������)��� �%+���� �� �%,��� ����&&-,�,.-&/,012��32,4-+��5.26+��%� � �������7&,.32��������%��� �8�� �(�'���������������� �� ���� 8����� �����)����� $����������9:���������� 8�������$�
�<���:������������������'�
�*�����������<�
����� �$�23�)���
� '������.#
� �'��$.$�;��(�$.$
� �'+�?,�".#
� �'�(�".$
� �'��$.#
� *����@����������".#
� ��*�."�(���
� ����$.#
� ����"."
� <�".#
� & <�".#
� ����:���*�����".#
� <������������"."
� �'+�$,#�"."
.��� ���23��** ��������
� (�!���������������������*+,�������)���� ��*)���������������� �-�* ��.���2��-�*/����������������� ��.���'�������0����!�������� ���� ���:�����������:���������
� +��������3���
�����0=
� '��������7��� �������
� ������������-�� �������������!������
� &�������������������
� �3�����������D��������������D�
� ���������'��������<�G
�4�#0�
� � ��������!����
� � �������!����
� �1 2�������� �����������
� � ������������
� �34'����������<�D������������'�
� � ������*���������-����������D�!����
)��>�&��&������'��
foo.ear
com/acme/Foo.class
WEB-INF/web.xmlWEB-INF/classes com/acme/FooServlet.class
com/acme/FooEJB.classcom/acme/FooEJBLocal.class
lib/foo_common.jar
foo_web.war
foo_ejb.jar
foo.war
WEB-INF/classes com/acme/Foo.class com/acme/FooServlet.class com/acme/FooEJB.class
� �
(��
���������4��������5�����������
� �
��5� � �*������+
���������� �����������C�����C;;��D�����.3��.���;:���� ���;�������;
� �
.���)��� ���(� �*���
� ���������������-�� �����������������������
���� ����
� ������������������
� java -jar glassfish.jar toto.war� <���:�������D���������$�
� mvn gf:run2�gf:start2�gf:deploy2�...� &��������������!�������;��������-��������-
� ��������������������:������
�)���0=
� '������� ���������������� �!������-��������
��!����!����!3����
� ��9(�������������
� �.:.�&�'��6>�=2�=1((<�
� '������������:���<
� ������������������:
� &����������<� ����-������L���-�������������
���������)-
2����(3���� �� �������$'��� ���;���� ������� ��� �'��� ���;���� ���$'��� ���<� �(=;��>?�@� �(���������������������������� �� <� �(�;��>�����$
����=;��>?����>���@� �(�,����;��>�����$
@� �(� ���������>������)��������� @�������>������� ���������� ��$
�262',��5�-3�;��>��42�2���� ���������.��231,0
���������)-���������
2����(3���� �� �������$'��� ���;���� ������� ��� �'��� ���;���� ���$'��� ���<� �(=;��>?�@� �(���������������������������� �� <� �(�;��>�����$
����=;��>?����>���@� �(�,����;��>�����$
@� �(� ���������>�����������������2���(����>�� ��4��56�� �����������$
'��������-�:��������
����$.#����������
���������)-�� ����������
2����(3���� �� �������$'��� ���;���� ������� ��� �'��� ���;���� ���$'��� ���<� �(=;��>?�@� �(���������������������������� �� <� �(�;��>�����$
����=;��>?����>���@� �(�,����;��>�����$
@� �(� ���������>�����������������2���(����>�� ��4��56�� ����������������)����42�����&&&&&) ����������&&&&&)��.������������)�����42�����$
7 �84��59����>�����������������)������:���2�@� �(��� �� ���6����$
,(� �<� �(=;��>?
(*������-�/�����
� &�������K� ��������-�<�3�������4& <5
� �'+�$%%�D�����'+�#�4�0�;���5
� &�����������:������4�����������52�
�����2������������2��������-���2������������
K�����
� *�������������������������
� <�3�����������������44���<���������<5
� �=� ������������������
� �
?�� ������/�����
�0�;������������'� ���������$
@�� ����4������� �������!��5�.�.�M�D��������N�O
��*��/������*����
� �
?�� ��������������
%,��� ���,012�32,4-+�1���32,2��5.26+��%� � �������7&,.32�%+���� �� ��:���,���������%��� �8�� ���������A�
������� �BB��(��C��@����8� �������������� ����'���� ��
���� � ���'���� ��������������"������(����A��
� �
?�� ������/�����
�0�;������������'� ���������$
@�� ����4������� �������!��5�.�.�M�D��������N�O
��*��/������*����
(*������-�/���������*
��*��&��� &'���5���>�����&�
&&�0�;���&&'���5���>�������7����0�&? ��&� ��%&&&&&&&&&&&&&&&&&&�=���*��&���242�'=�@0�6'1=@�&&&&&&&&&&&&&&&&&&��2��������� ��&����� ��%&&&&&&&&&&&&&&&&&&�@�,����&'���&�����&�&&&&)))&&�
�
� �
��'���������� �����3�������� �4�9
EJBContainer c = EJBContainer.createEJBContainer();
Context ic = c.getContext();
SimpleEjb ejb = (SimpleEjb)ic.lookup("java:global/sample/SimpleEjb");
ejb.sayHello();
� �
��'���������� �����3�������� �4�9
EJBContainer c = EJBContainer.createEJBContainer();
Context ic = c.getContext();
SimpleEjb ejb = (SimpleEjb)ic.lookup("java:global/sample/SimpleEjb");
ejb.sayHello();
=�D������*�."
�����!����= <�����
� �
��'���������� �����3�������� �4�9
@Test public void test() {
EJBContainer c = EJBContainer.createEJBContainer();
Context ic = c.getContext();
SimpleEjb ejb = (SimpleEjb)ic.lookup("java:global/sample/SimpleEjb");
ejb.sayHello();
}
���
� �
� �������� �3���
org.glassfish.api.embedded.Server server; Server.Builder builder = new Server.Builder(); server = builder.build();
� �
� �������� �3���
org.glassfish.api.embedded.Server server; Server.Builder builder = new Server.Builder(); server = builder.build();
ContainerBuilder b =server.createConfig(ContainerBuilder.Type.web);
server.addContainer(b);
� �
� �������� �3���
org.glassfish.api.embedded.Server server; Server.Builder builder = new Server.Builder(); server = builder.build();
ContainerBuilder b =server.createConfig(ContainerBuilder.Type.web);
server.addContainer(b);
File archive = new File("hello.war"); server.getDeployer().deploy(archive);
'����!���2��� ����������-������
�������������+������!��
� �
� �������� �3���
@BeforeClass public static void initContainer() { org.glassfish.api.embedded.Server server; Server.Builder builder = new Server.Builder(); server = builder.build();
ContainerBuilder b =server.createConfig(ContainerBuilder.Type.web);
server.addContainer(b);
File archive = new File("hello.war"); server.getDeployer().deploy(archive);
}
@Test public static void pingApplication() { ...
}
� �
� �������� �3���
public static void main(String[] args) { org.glassfish.api.embedded.Server server; Server.Builder builder = new Server.Builder(); server = builder.build();
ContainerBuilder b =server.createConfig(ContainerBuilder.Type.web);
server.addContainer(b);
File archive = new File("realApplication.war"); server.getDeployer().deploy(archive);
}
'������������������������������������
� �
2���7������� �'����%���9
� ����������������������� �8'���4������!-��� ����5
� ���������������� ��������L������4����E��� ��� ���5
� �������������������$##B�!������
� &�������D�������8'���4'����������5
� &�������8'�������:������������4&(<����6�!5
� &���!�������������������� ��������:�8'����������
� ��-�8'���!������D���������������������
� ����������glassfish/modules{/autostart}� &��������asadmin deploy��������:���type osgi� ����������8'����������������
� �
������&�� ���������#%���;��� �6�������* 5�������������*�����
� 8'��������������������
� Service-Component�����-����������+����� ���
� <���������������� ������
�����������:����������
@Resource���3������
� =��������������������
��<�G
� =����������������
!��D����8'������
������
'����!-�����C�����C;;!��:�.���.���;�����7;����-;:���� ���PP����������P����P?�
� �
(��
��������:�����������
8'�����-��
� �
������&�� ���������#�*���&(.�6�����������* 5���������*�����
� �����������������D����
��������� ����'����:����
���������
� '������'����:�!����
�����������:�����������
� <���������������� ������
�����������:����������
@Resource���3������� '������������� ���
������������<
� '��:����������� ���!����
'����:����� ����������
'����!-�����C�����C;;!��:�.���.���;�����7;����-;:���� ���PP����������P����P?�
� �
%����A������ �B���3�����**�
� ��������������������������������
� �����!����������������-
� ������������46�!�K�&(<5
� <��������������� ����������������8'���
��������K����������
� 8'���+�&A�
� '������� ���������������� ���
� �.:.����2���*2�� *&2����2�...����8'����������
� 6�!�������������*������46�*5
� 6�+�B�8'������������B�6�!�&�����������������
� �
C*��������
� �
.��������&�����.���&���4�����'3������ �����asadmin
� -��������������������������������:�� �������
������-��������������������������� *����������:�������
��DG
� �����!��2��-������������ ��������:������ ������
� *������������������������<����D������������
� ���!������������� ��������3������)�(���DG
� � ��������������K����������-�����D�
� +�'� �������� �������DG
� ������ ����������������DG
� '������������������)� jconsole�����visualvm�������������������
� �
, ��� ������
� ��)�+';�����-�B����77�-�����������+�'��
����� ��������C� &�� �:������������4������2��8'�2� �(���5
� <��������������4�������2�����2������-2����..5
� ���������:�4�������-5
� �����!��� ����C� http://localhost:4848/management/domain � http://localhost:4848/monitoring/domain
� 1���+�'��������������������1<���!�������� 1���-��� �������:���;��������:����:��:���������
� ����� ���������������)�(2�>��(�����'8=
� �������!��
� �
(��
+�'� ��������
� �
�� �������000
� -���������:��:��
� +����2�������2� 3��:�2�'����;(� �...
� ��-���6�!
� &����2�����������2�6�!'������2�...
� ������������� ���C
� ���P3�
� 6�! �@2�&�<2�''<
� 6�!�'������������
� .=���.,��������
� 8����9���������
� �
� ��������6�)�������
� ������� ��������C;;:���� ���.��:� ����������.#."������!���4����1&����������� ����5
� ����� ��������C;;DDD.������.���;:���;:���� ���
4���8����� �D��������:������ ������.5
� &������G� �����������=��*�����4����...5
� ����������L�����
� ����������<��������2�R���������
� �D��������7���������:�����*� &������� ����6�!���� ������� �������� ���
� �
��& �������� ��������%� �#0�
� >�:�������:���
� &��!��������!��� ���� ����$."."�����.#
� &��������:2�������������������������7��������� ����$."."
� 8'������������-�������������� ����.�
� ��������������������������
� �
����� ��������#0����&� �&���
� *��������������:�4�"5
� ���.���������:�4�"5
� +�'� �����<�4�"5
� '��!���7����!������
� '���������:��77�-
� ������+��K�'��&���
�������� ������
� +������'�'*;��*�������
��������������-�
� �������������������
���������
� 6�!'�������4������77�-5
� ����������������8'��
� 1�������< �����:���
� <�������& <�����:������
� ��������:-��� ����C��'�2�
& <2����77�-2�8'��2����2�
�����-2�*����@���������2�
�����2�1&2����.
� 6'�<�����������C�*��
".$;$.#2�*'�2�"."2�+'��".#
� ���������...
� �
������.��I���.���
����C;;!��:�.���.���;��������
�D�����C���������
?�������